package com.example.hospitalapp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

public class DoctorAppointmentAdapter extends BaseAdapter {

    private Context context;
    private List<Appointment> appointments;

    public DoctorAppointmentAdapter(Context context, List<Appointment> appointments) {
        this.context = context;
        this.appointments = appointments;
    }

    @Override
    public int getCount() {
        return appointments.size();
    }

    @Override
    public Object getItem(int position) {
        return appointments.get(position);
    }

    @Override
    public long getItemId(int position) {
        return appointments.get(position).getAppointmentId();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_doctor_appointment, parent, false);
        }

        Appointment appointment = appointments.get(position);

        TextView txtAppointmentTime = convertView.findViewById(R.id.txtAppointmentTime);
        TextView txtStatus = convertView.findViewById(R.id.txtStatus);
        TextView txtPaymentStatus = convertView.findViewById(R.id.txtPaymentStatus);

        // 设置预约信息
        txtAppointmentTime.setText("预约时间: " + appointment.getAppointmentTime());
        txtStatus.setText("状态: " + appointment.getStatus());
        txtPaymentStatus.setText("支付状态: " + appointment.getPaymentStatus());

        return convertView;
    }
}
